define(function(require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function() {
        controller.vm = new Vue({
            router: router,
            data: function() {
                return {
                    shop_info: {},
                    store:{},
                    loading:0,
                    cardQrcodeInfo:{},
                    show_qrcode_url:''
                    
                };
            },
            el: '#pageBindScanBox',
            created: function() {
                this.fetchData();
            },
             mounted: function() {
                if (this.mounted == 1) {
                    return;
                }
                this.mounted = 1;
                // app.copy("#shareClipboard",function(res){
                //    console.log(res);
                //    if(res=="success"){
                //      app.alert("链接复制成功");
                //    }else{
                //      this.share();
                //    }
                // });
            },

            methods: {
                fetchData: function() {
                    var _this = this;

                    // this.getInfo();
                    this.getCardQrcode();
                   
                },
                getCardQrcode:function(){
                  //如果是微信打开卡包
                   var that = this;
                   app.get("/apiv2/pay_request/bindScanBox/",{shop_id:this.$route.params.shop_id},function(res){
                       if(res.code!=200){
                         app.alert(res.msg);
                         return;
                       }

                      that.show_qrcode_url= app.params.apiDomain+"/api/index/urlQRcode?url="+encodeURIComponent(res.data);
                       
                       
                   });
                },
                
                 share:function(){
                  var text = '复制链接发给朋友：'+this.url ;
                  if(app.isWeiXin()){
                    text = "请点击微信右上角分享给好友";
                  }
                  app.confirm({
                    text:text
                  });
                }
            }

        }).$mount('#app');
    };
    module.exports = controller;
});
